package com.atguigu.yygh.task.scheduled;

import com.atguigu.common.rabit.constant.MqConst;
import com.atguigu.common.rabit.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @ClassName ScheduledTask
 * @Description: 定时任务
 * @Author: liangxiaoqiang
 * @CreateDate: 2024/8/10 15:19
 * @UpdateUser: 更新人
 * @UpdateDate: 2024/8/10 15:19
 * @UpdateRemark: 更新的信息
 * @Version: 1.0
 */

@Component
// 开启定时任务
@EnableScheduling
public class ScheduledTask {

    @Autowired
    private RabbitService rabbitService;

    /**
     * 每天8点执行 提醒就诊
     */
    //0 0 8 1/1 * ? 字符最少是六个
//    @Scheduled(cron = "0 0 8 1/1 *")  // 每天8点执行
    @Scheduled(cron = "0/30 * * * * *") // 每30秒执行一次
    public void task1() {
        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK, MqConst.ROUTING_TASK_8, "");
    }
}

